﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using e_bank;
using gds_classes;
using e_customer;
using e_shop;

namespace e_money
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter P (big prime int)");
            int p = int.Parse(Console.ReadLine());
            if (!MathMethods.IfPrime(p))
            {
                Console.WriteLine("the number is not prime");
                return;
            }

            Console.WriteLine("Enter Q (big prime int)");
            int q = int.Parse(Console.ReadLine());
            if (!MathMethods.IfPrime(q))
            {
                Console.WriteLine("the number is not prime");
                return;
            }

            if (p == q)
            {
                Console.WriteLine(" p = q ");
                return;
            }

            Console.WriteLine("Enter customer's cash rate: ");
            int rate = int.Parse(Console.ReadLine());

            Bank bank = new Bank(p, q, rate);

            Console.WriteLine("Enter customer's balance: ");
            int balance = int.Parse(Console.ReadLine());
            bank.Balance = balance;

            Customer customer = new Customer(bank.N, bank.d);
            
            bool exit=false;

            Shop shop = new Shop(bank);

            while (!exit)
            {
                Console.WriteLine("Enter cash number: ");
                int cash_number = int.Parse(Console.ReadLine());

                var t2 = customer.GetAnonymousN(cash_number);

                var t1 = bank.GetCash(t2);
                
                var cash = customer.EvaluteCash(t1);


                var success = shop.Buy(cash);
                if (success)
                {
                    Console.WriteLine("Success!");
                }
                else
                {
                    Console.WriteLine("Denied!");
                }

                Console.WriteLine("Type \"exit\" to exit: ");
                if (Console.ReadLine()=="exit")
                {
                    exit = true;
                }
            }

            

        }
    }
}
